<template>
  <div class="feedbackPro">
    <div class="container">
      <div class="search-card">
        <div class="search-argument">
          <!-- 反馈类型 -->
          <div class="search-item">
            <span class="labelName">反馈类型</span>
            <el-select
              v-model="feedbackType"
              class="search-input"
              placeholder="请选择"
            >
              <el-option
                v-for="item in feedbackTypeList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </div>
          <!-- 业务模块 -->
          <div class="search-item">
            <span class="labelName">业务模块</span>
            <el-select
              v-model="moduleType"
              class="search-input"
              placeholder="请选择"
            >
              <el-option
                v-for="item in moduleList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </div>
          <!-- 反馈时间 -->
          <div class="search-item">
            <span class="labelName">反馈时间</span>
            <el-date-picker
              v-model="applicateTime"
              class="search-time"
              type="daterange"
              range-separator="至"
              start-placeholder="开始时间"
              end-placeholder="结束时间"
            />
          </div>
          <!-- 搜索按钮 -->
          <div class="search-button">
            <div class="btn search">
              <el-icon class="icon" color="#fff"> <Search /> </el-icon>搜索
            </div>
            <div class="btn reset">
              <el-icon class="icon" color="rgba(43, 193, 123, 1)">
                <Refresh /> </el-icon
              >重置
            </div>
          </div>
        </div>
      </div>

      <!-- 表格数据 -->
      <el-table
        v-loading="loading"
        max-height="60vh"
        :data="feedbackData"
        :border="true"
      >
        <el-table-column type="index" label="序号" width="80" align="center" />
        <el-table-column
          label="标题"
          prop="title"
          :show-overflow-tooltip="true"
          min-width="100"
          align="center"
        />
        <el-table-column
          label="反馈类型"
          :show-overflow-tooltip="true"
          min-width="100"
          align="center"
        >
          <template #default="{ row }">
            <span>{{ getFeedType(row.feedbackType) }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="业务模块"
          :show-overflow-tooltip="true"
          min-width="100"
          align="center"
        >
          <template #default="{ row }">
            <span>{{ getModule(row.moduleType) }}</span>
          </template>
        </el-table-column>
        <el-table-column label="反馈时间" align="center" min-width="120">
          <template #default="{ row }">
            <span>{{ row.startTime }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="反馈人"
          prop="user"
          :show-overflow-tooltip="true"
          min-width="100"
          align="center"
        />
        <el-table-column
          label="手机号码码"
          prop="phone"
          :show-overflow-tooltip="true"
          min-width="100"
          align="center"
        />
        <el-table-column
          label="操作"
          align="center"
          min-width="120"
          class-name="small-padding fixed-width"
        >
          <template #default="{ row }">
            <el-button
              link
              type="primary"
              @click="openDialog(row)"
              v-hasPermi="['airTask:airspace:detail']"
              >详情</el-button
            >
          </template>
        </el-table-column>
      </el-table>

      <!-- 分页 -->
      <pagination
        v-show="total > 0"
        :total="total"
        v-model:page="pageNum"
        v-model:limit="pageSize"
        @pagination="initData"
        class="pagination"
      />

      <!-- 详情弹出层 -->
      <el-dialog
        v-model="dialogVisible"
        title="反馈详情"
        class="add-dialog"
        :close-on-click-modal="false"
      >
        <el-form
          label-width="100px"
          ref="feedbackFormRef"
          :model="feedbackForm"
          :rules="rules"
        >
          <el-form-item label="详情标题" prop="title">
            <el-input
              disabled
              v-model="feedbackForm.title"
              placeholder="请输入使用帮助标题"
            />
          </el-form-item>
          <el-form-item label="反馈类型" prop="title">
            <el-select
              disabled
              v-model="feedbackForm.feedbackType"
              placeholder="请选择"
              style="width: 100%"
            >
              <el-option
                v-for="item in feedbackTypeList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="业务模块" prop="title">
            <el-select
              disabled
              v-model="feedbackForm.moduleType"
              placeholder="请选择"
              style="width: 100%"
            >
              <el-option
                v-for="item in moduleList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="备注说明">
            <el-input
              disabled
              v-model="feedbackForm.remark"
              :rows="3"
              type="textarea"
            />
          </el-form-item>
          <el-form-item label="反馈图片">
            <div class="images">
              <img
                v-for="item in feedbackForm.img"
                :key="item"
                :src="item"
                alt=""
              />
            </div>
          </el-form-item>
          <el-form-item label="反馈文件" prop="file">
            <div class="createBtn">
              <img src="@/assets/images/choice.png" alt="" />上传
            </div>
          </el-form-item>
          <el-form-item label="反馈人" prop="user">
            <el-input
              disabled
              v-model="feedbackForm.user"
              placeholder="请输入反馈人姓名"
            />
          </el-form-item>
          <el-form-item label="手机号码码" prop="phone">
            <el-input
              disabled
              v-model="feedbackForm.phone"
              placeholder="请输入手机号码码"
            />
          </el-form-item>
          <div class="dialogFoot">
            <div class="btn delete" @click="dialogVisible = !dialogVisible">
              关闭
            </div>
          </div>
        </el-form>
      </el-dialog>
    </div>
  </div>
</template>
<script>
export default {
  name: "FeedbackProblem",
};
</script>
<script setup>
import { reactive, ref } from "vue";
import { useRouter } from "vue-router";

const feedbackType = ref(0);
const applicateTime = ref();
const moduleType = ref(0);
const loading = ref(false);
const feedbackData = ref([
  {
    title: "系统更新通知",
    file: "",
    feedbackType: 1,
    moduleType: 3,
    user: "张三",
    phone: "15687987657",
    startTime: "2023-10-23 13:00",
    remark: "测试",
    img: [
      "https://img.js.design/assets/smartFill/img429164da758808.jpg",
      "https://img.js.design/assets/smartFill/img429164da758808.jpg",
      "https://img.js.design/assets/smartFill/img429164da758808.jpg",
    ],
  },
  {
    title: "飞行区域状态变更通知",
    file: "",
    feedbackType: 2,
    moduleType: 5,
    startTime: "2023-10-23 13:00",
    user: "李四",
    phone: "15687987657",
    remark: "测试111111111",
    img: ["https://img.js.design/assets/smartFill/img429164da758808.jpg"],
  },
  {
    title: "范围气象变化通知",
    file: "",
    feedbackType: 3,
    moduleType: 1,
    startTime: "2023-10-23 13:00",
    user: "王五",
    phone: "15687987657",
    remark: "测试",
    img: [
      "https://img.js.design/assets/smartFill/img429164da758808.jpg",
      "https://img.js.design/assets/smartFill/img429164da758808.jpg",
    ],
  },
  {
    title: "范围气象变化通知",
    file: "",
    feedbackType: 1,
    moduleType: 2,
    startTime: "2023-10-23 13:00",
    user: "赵六",
    phone: "15687987657",
    remark: "测试",
    img: [
      "https://img.js.design/assets/smartFill/img429164da758808.jpg",
      "https://img.js.design/assets/smartFill/img429164da758808.jpg",
    ],
  },
  {
    title: "飞行区域状态变更通知",
    file: "",
    feedbackType: 2,
    moduleType: 4,
    startTime: "2023-10-23 13:00",
    user: "孙七",
    phone: "15687987657",
    remark: "测试",
    img: ["https://img.js.design/assets/smartFill/img429164da758808.jpg"],
  },
  {
    title: "系统更新通知",
    file: "",
    feedbackType: 3,
    moduleType: 6,
    startTime: "2023-10-23 13:00",
    user: "钱八",
    phone: "15687987657",
    remark: "测试",
    img: [
      "https://img.js.design/assets/smartFill/img429164da758808.jpg",
      "https://img.js.design/assets/smartFill/img429164da758808.jpg",
      "https://img.js.design/assets/smartFill/img429164da758808.jpg",
    ],
  },
]);
const dialogVisible = ref(false);
const feedbackTypeList = reactive([
  {
    label: "全部",
    value: 0,
  },
  {
    label: "功能异常",
    value: 1,
  },
  {
    label: "产品改进",
    value: 2,
  },
  {
    label: "其它问题",
    value: 3,
  },
]);
const moduleList = reactive([
  {
    label: "全部",
    value: 0,
  },
  {
    label: "登录",
    value: 1,
  },
  {
    label: "注册",
    value: 2,
  },
  {
    label: "飞行任务",
    value: 3,
  },
  {
    label: "驾驶舱",
    value: 4,
  },
  {
    label: "报警设置",
    value: 5,
  },
  {
    label: "公共信息",
    value: 6,
  },
]);
const total = ref(3);
const pageNum = ref(1);
const pageSize = ref(10);

// -------------------------------------------------  表单事件  -----------------------------------------------------
let feedbackForm = reactive({});

/**
 * @初始化表单
 * */
function initForm() {
  return {
    title: "",
    file: "",
    feedbackType: "",
    moduleType: "",
    user: "",
    phone: "",
    remark: "",
    img: "",
  };
}

/**
 * @打开弹出层
 * */
function openDialog(row) {
  dialogVisible.value = true;
  feedbackForm = row;
}
/**
 * @获取反馈类型
 * */
function getFeedType(val) {
  let type = feedbackTypeList.find((item) => item.value === val);
  if (type) return type.label;
  else return "其它";
}
/**
 * @获取业务模块
 * */
function getModule(val) {
  let module = moduleList.find((item) => item.value === val);
  if (module) return module.label;
  else return "其它";
}
</script>

<style lang="scss">
.feedbackPro {
  .add-dialog {
    top: 100px;
    width: 560px;
    border-radius: 4px;
  }

  .add-dialog .el-dialog__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0;
    padding: 20px;
    height: 58px;
    color: #fff !important;
    background: rgba(32, 39, 65, 1);

    .el-dialog__title {
      color: #fff !important;
    }
    .el-dialog__headerbtn {
      top: 0 !important;
      width: 58px;
      height: 58px;
      color: #fff !important;
    }
  }
  .add-dialog .el-dialog__body {
    padding: 20px;

    .images {
      display: flex;
      flex-wrap: wrap;
      justify-content: flex-start;
      align-items: center;
      width: 425px;
      img {
        width: 100px;
        height: 100px;
        border-radius: 4px;
        margin: 0 5px;
      }
    }

    .dialogFoot {
      width: 100%;
      height: 60px;
      line-height: 60px;
      text-align: center;
      // margin: 20px 0;
      display: flex;
      justify-content: center;
      align-items: center;
      .btn {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 81px;
        height: 32px;
        padding: 10px;
        margin-right: 14px;
        font-size: 14px;
        border-radius: 4px;
        user-select: none;
        border: 1px solid rgba(220, 223, 230, 1);
        cursor: pointer;
        &:hover {
          background: rgba(0, 0, 0, 0.1);
        }
      }
      .btn.search {
        color: #fff;
        background: rgba(43, 193, 123, 1);
        border: 1px solid rgba(43, 193, 123, 1);
        &:hover {
          background: rgba(43, 193, 123, 0.85);
        }
      }
    }
  }

  .search-item .search-input .el-input,
  .search-time .el-date-editor {
    height: 40px !important;
  }
}
</style>

<style scoped lang="scss">
.feedbackPro {
  width: 100%;
  height: 100%;

  .container {
    position: relative;
    width: calc(100% - 40px);
    height: 92%;
    margin: 0 20px 20px;
    border-radius: 10px;
    background: white;

    .pagination {
      position: absolute;
      left: 50%;
      bottom: 30px;
      transform: translateX(-50%);
    }
  }

  .search-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    padding: 30px 0;
    width: 100%;
    height: 100px;
    border-radius: 10px;
    background-color: #fff;
  }

  .search-argument {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-content: flex-start;
    gap: 20px;

    .search-item {
      display: flex;
      justify-content: flex-start;
      align-items: center;
      width: 24%;
      height: 40px;

      .search-input {
        flex: 1;
        width: 270px;
        height: 40px;
      }

      .search-time {
        flex: 1;
        width: 270px;
        height: 40px;
      }
    }

    .labelName {
      width: 80px;
      text-align: right;
      font-size: 14px;
      margin-right: 15px;
    }

    .search-button {
      position: absolute;
      right: 0px;
      top: -45px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      width: 160px;
      height: 40px;
    }
  }

  .batch-operation {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    position: absolute;
    right: 180px;
    top: -45px;
    height: 40px;
  }

  .tag {
    display: inline-block;
    width: 80px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    border-radius: 15px;
    color: rgba(153, 153, 153, 1);
    border: 1px solid rgba(153, 153, 153, 1);
  }
  .tag.warning {
    color: rgba(255, 149, 18, 1);
    border: 1px solid rgba(255, 149, 18, 1);
  }
  .tag.success {
    color: rgba(43, 193, 123, 1);
    border: 1px solid rgba(43, 193, 123, 1);
  }

  .btn {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 34px;
    padding: 10px;
    font-size: 14px;
    border-radius: 4px;
    user-select: none;
    cursor: pointer;
  }
  .btn.search {
    color: #fff;
    background: rgba(43, 193, 123, 1);
    &:hover {
      background: rgba(43, 193, 123, 0.85);
    }
  }

  .btn.reset {
    color: rgba(43, 193, 123, 1);
    background: rgba(43, 193, 123, 0.05);
    border: 1px solid rgba(43, 193, 123, 1);
    &:hover {
      background: rgba(43, 193, 123, 0.2);
    }
  }

  .btn.remove {
    color: rgba(255, 149, 18, 1);
    background: rgba(255, 149, 18, 0.05);
    border: 1px solid rgba(255, 149, 18, 1);
    &:hover {
      background: rgba(255, 149, 18, 0.2);
    }
  }

  .icon {
    margin-right: 6px;
  }
}
</style>
